import { StationNetwork } from "GameLoop/Path/StationNetwork";
import { WorldState } from "GameLoop/WorldState/worldstate";
import { GlobalStateUpdate } from "./CheckFunction/Global/GlobalStateUpdate";
import { GlobalEventCheck } from "./CheckFunction/Global/GlobalEventCheck";


/*@profile*/
export class GlobalEvent implements IEventCheck<IGlobalEventChecker,any>
{
    _tickStart: Record<string, IGlobalEventChecker[]>={};
    _tickEnd: Record<string, IGlobalEventChecker[]>={};
    _world!:WorldState;
    _eventTrigger!:TEventEmitter<TEventTypes>;
    init( _world:WorldState,_eventTrigger:TEventEmitter<TEventTypes>)
    {
        this._world = _world;
        this._eventTrigger = _eventTrigger

        
    }
    
    public initEvent()
    {
        this._tickStart={
            [Game.shard.name]:[
                GlobalStateUpdate.checkExpireCreeps,
                GlobalEventCheck.checkResourceBlance,
                GlobalStateUpdate.checkUpdateMarket
            ],
             
        }

        this._tickEnd={
            [Game.shard.name]:[    
                GlobalEventCheck.checkExpireRooms            
            ],
        }
    }
    public tickStart(world:WorldState)
    {
        
        this._tickStart[Game.shard.name].forEach(e=>{
            e(world,this._eventTrigger)
        })
    }
    public tickEnd(world:WorldState)
    {
        this._tickEnd[Game.shard.name].forEach(e=>{
            e(world,this._eventTrigger)
        })
    }
}